#!/usr/bin/ksh


# HP-UX postinstall steps

# If the required link in run level three does not exist
# then add it...

ostype=$(uname)
if [[ "$ostype" = HP-UX && ! -a /sbin/rc3.d/S900bac_dbm_gri ]]
then
	cd /opt/gri_backend/init.d
	cp -f gri_authd gri_backend gri_secure_dir_writer /sbin/init.d
	chmod 550 /sbin/init.d/gri_authd /sbin/init.d/gri_backend /sbin/init.d/gri_secure_dir_writer
	cd /sbin/rc3.d
	ln -sf ../init.d/gri_authd S900gri_authd
	ln -sf ../init.d/gri_backend S900gri_backend
	ln -sf ../init.d/gri_secure_dir_writer S900gri_dwriter
	cd /sbin/rc2.d
	ln -sf ../init.d/gri_authd K900gri_authd
	ln -sf ../init.d/gri_backend K900gri_backend
	ln -sf ../init.d/gri_secure_dir_writer K900gri_dwriter
	cd /sbin/rc1.d
	ln -sf ../init.d/gri_authd K900gri_authd
	ln -sf ../init.d/gri_backend K900gri_backend
	ln -sf ../init.d/gri_secure_dir_writer K900gri_dwriter
fi

if [[ "$ostype" = HP-UX  && ! -a /etc/rc.config.d/gri_backend ]]
then
	cd /opt/gri_backend/rc.config.d
	cp -f gri_backend.example /etc/rc.config.d/gri_backend
fi

# HP-UX postinstall steps end

# AIX post install steps ...

if [[ "$ostype" = AIX ]]
then
	if [[ ! -a /etc/rc.d/rc2.d/Src.local ]]
	then
		/usr/bin/touch /etc/rc.d/rc2.d/Src.local
		/usr/bin/chmod 550 /etc/rc.d/rc2.d/Src.local
		/usr/bin/chown root.system /etc/rc.d/rc2.d/Src.local
	fi

	if [[ ! -a /etc/rc.d/rc2.d/Krc.local ]]
	then
		/usr/bin/touch /etc/rc.d/rc2.d/Krc.local
		/usr/bin/chmod 550 /etc/rc.d/rc2.d/Krc.local
		/usr/bin/chown root.system /etc/rc.d/rc2.d/Krc.local
	fi

	# Add the entries to start the backend server for now, no
	# authd support as yet...

	z=`egrep '^/opt/gri_backend/bin/start-gri_backend.aix' /etc/rc.d/rc2.d/Src.local
	if [ -z "$z" ]
	then
		echo /opt/gri_backend/bin/start-gri_backend.aix >> /etc/rc.d/rc2.d/Src.local
	fi

	z=`egrep '^/opt/gri_backend/bin/stop-gri_backend.aix' /etc/rc.d/rc2.d/Krc.local
	if [ -z "$z" ]
	then
		echo /opt/gri_backend/bin/stop-gri_backend.aix >> /etc/rc.d/rc2.d/Krc.local
	fi
fi
# AIX post install steps end

exit 0

